package com.money.shell.view
{
	import com.money.shell.ShellFacade;
	import com.money.shell.view.ui.MenuBar;
	
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import mx.collections.ArrayCollection;
	import mx.collections.XMLListCollection;
	import mx.controls.Alert;
	import mx.controls.Image;
	import mx.core.IVisualElementContainer;
	import mx.events.FlexEvent;
	import mx.events.MenuEvent;
	import mx.utils.ArrayUtil;
	
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;

	public class MenuBarMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "MenuBarMediator";
		public function MenuBarMediator(viewComponent:com.money.shell.view.ui.MenuBar)
		{
			super(NAME, viewComponent);
		}
		private function get menuBar():MenuBar
		{
			return viewComponent as MenuBar;
		}
		override public function onRegister():void
		{
			menuBar.addEventListener(MenuEvent.ITEM_CLICK,menuItemClcikHandle);
		}
		public function menuItemClcikHandle(event:MenuEvent):void
		{
			Alert.show(menuBar.selectedIndex.toString(10));
		}
		override public function onRemove():void
		{
		}
		override public function listNotificationInterests():Array
		{
			return [ShellFacade.MENUINI,];
		}
		
		override public function handleNotification(note:INotification):void
		{
			switch (note.getName())
			{
				case ShellFacade.MENUINI:
					var menulist:ArrayCollection=note.getBody() as ArrayCollection;
					menuBar.dataProvider=menulist;
					break;
			}
		}
	}
}